public class RandomContactFactory {
    public static List<Contact> generateRandomContacts(Integer contactNum, String lastName) {
        List<Contact> contactList = new List<Contact>();
        for(Integer i = 0; i < contactNum; i++) {
            contactList.add(new Contact(FirstName='aa'+i, LastName=lastName+' '+i));
        }
        insert contactList;
        return contactList;
    }
}